package SwingStudy;

import javax.swing.*;
import java.awt.*;

/**
 * 边界布局BorderLayOut
 * 尽可能的充满整个界面
 */
public class BorderLayoutTest extends JFrame {
    JButton northBtn = new JButton("北边的按钮");
    JLabel southLabel = new JLabel("南边的Label");
    JRadioButton westRadioBtn = new JRadioButton("西边的男");
    JTextArea eastArea = new JTextArea("东边的输入内容", 10, 20);
    JButton centerBtn = new JButton("中间的按钮");

    public BorderLayoutTest() {
        super("测试边界布局");

        Container contentPane = getContentPane();
        //设置布局管理器
        contentPane.setLayout(new java.awt.BorderLayout());
        contentPane.add(northBtn, BorderLayout.NORTH);
        //0为默认值
        northBtn.setPreferredSize(new Dimension(0, 200));
        contentPane.add(southLabel, BorderLayout.SOUTH);
        westRadioBtn.setPreferredSize(new Dimension(200, 0));
        contentPane.add(westRadioBtn, BorderLayout.WEST);
        contentPane.add(eastArea, BorderLayout.EAST);
        contentPane.add(centerBtn, BorderLayout.CENTER);


        setSize(1000, 600);
        setLocationRelativeTo(null);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setVisible(true);
    }

    public static void main(String[] args) {
        new BorderLayoutTest();
    }
}